package com.javatest.springboot.controller;

import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author lzy
 * @version v1.0
 * Create DateTime: 2019/1/4 17:01
 */
@Controller
public class HelloController {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    @ResponseBody
    @RequestMapping("/query")
    public Map<String, Object> map() {
        String sql = "select * from test_table";
        List<Map<String, Object>> maps = jdbcTemplate.queryForList(sql);
        return maps.get(0);
    }
}
